/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui2;

import java.awt.Color;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.text.DefaultCaret;

public class OutputWindow  extends JFrame implements outputInterface{
    
     private JTextArea textArea = new JTextArea();
     private JScrollPane areaScrollPane = new JScrollPane(textArea);
     

    
     public OutputWindow(int width, int height) {
            this.setSize(width, height);
            this.setTitle("Output Window");
            this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            this.setLocation(930, 230);
            this.setResizable(false);
            InitComponents();
            this.show();        
    }
    
    private void InitComponents(){
        
        DefaultCaret caret = (DefaultCaret) textArea.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        
        
        textArea.setForeground(Color.green);
        textArea.setBackground(Color.black);
        textArea.setEditable(false);
        
        add(areaScrollPane);
    }
    
    public void PrintToScreen(String message) {
        textArea.setText(textArea.getText() + message+"\n");
    }
    
    public void CleanScreen() {
        textArea.setText("");
    }

    @Override
    public void printToOutput(String text) {
        PrintToScreen(text);
    }
}
